package com.ydlclass.handler;

import com.ydlclass.factory.proxy.PendingRequests;
import com.ydlclass.message.YrpcMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * @author it楠老师
 * @createTime 2023-03-16
 * 处理服务端的请求的handler
 */
@Slf4j
public class ProcessYrpcMessageHandler extends SimpleChannelInboundHandler<YrpcMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, YrpcMessage yrpcRequestMessage) throws Exception {
        // 将载荷包装存储至全局
        PendingRequests.getInstance().complete(yrpcRequestMessage);
        if(log.isDebugEnabled()){
            log.debug("---> Message requestId[{}] is completed.",yrpcRequestMessage.getRequestId());
        }
    }

}
